<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>后台管理</title>
    <link rel="stylesheet" type="text/css" href="/css/nav.css">
    <link rel="stylesheet" type="text/css" href="/font/iconfont.css">
    <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="/js/nav.js"></script>
    <link rel="stylesheet" href="/layui/css/layui.css">

</head>
<body>
<div class="nav" style="float: left;" th:include="/common/nav :: nav"></div>
<div style="float: left;height: 100%;width: 87.5%;background-color: rgb(235, 243, 243);" >
    <div class="content">

        <div class="layui-form-item" style="font-size:30px;text-align: center;font-weight: bolder">运输途中的包裹：</div>

        <table class="layui-table">
            <colgroup>
                <col width="150">
                <col width="200">
                <col>
            </colgroup>
            <thead>
            <tr>
                <th>单号</th>
                <th>寄件人</th>
                <th>寄件人电话</th>
                <th>寄件人地址</th>
                <th>收件人</th>
                <th>收件人电话</th>
                <th>收件人地址</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="item : ${packages}">
                <td class="pno" th:text="${item.getNo()}"></td>
                <td th:text="${item.getSendName()}"></td>
                <td th:text="${item.getSendAddress()}"></td>
                <td th:text="${item.getSendPhone()}"></td>
                <td th:text="${item.getReceiptName()}"></td>
                <td th:text="${item.getReceiptPhone()}"></td>
                <td th:text="${item.getReceiptAddress()}"></td>
                <td th:text="${item.getCreateTime()}"></td>
                <td><button type="button" class="layui-btn layui-btn-radius layui-btn-normal change-state-button">转为待派件状态</button></td>
            </tr>

            </tbody>
        </table>
    </div>
</div>
<script src="/layui/layui.all.js"></script>
<script>
    $(document).ready(function () {

        $(".change-state-button").click(function () {

            var $tr=$(this).parent().parent();
            var $pno = $tr.children("td.pno").text();
            layer.confirm('是否改变此包裹状态为待派件？', {
                btn: ['是','否'] //按钮
            }, function(){


                $.get("/admin/changePackageState",{
                    "pNo":$pno,
                    "state":3
                },function (data) {

                    layer.msg("更改成功！"+$pno,{icon:6});

                    $tr.remove();
                });

            }, function(){

            });

        });
    });

</script>
</body>
</html>
